export * from './public'

const env = 'browser'

// event on|off
function on(ele,ev,listener,option){
    if(document.addEventListener ){
        ele.addEventListener(ev,listener,option)
    }else{
        ele.attachEvent(ev,listener)
    }
}

function off(ele,ev,listener,option){
    if(document.removeEventListener){
        ele.removeEventListener(ev,listener,option)
    }else{
        ele.detachEvent(ev,listener)
    }
}

// DOM rooterElement
function rooter (){
    return document.documentElement || document.body
} 

// DOM ready
function ready (cb){
    on(document,'DOMContentLoaded',cb)
}

// 获取网页一屏|整个网页|页面元素的宽高
// offsetWidth|offsetHeight|offsetLeft|offsetTop|clientWidth|clientHeight|clientLeft|clientTop
// 设置|获取网页|溢出元素滚动条的滚动距离
// scrollWidth|scrollHeight|scrollLeft|scrollTop
function box(ele,atr,val){
    if(arguments.length <3){
        return  ele[atr]
    }else{
        ele[atr] = val 
    }
}


// export default defaultExport
export {
    env,
    on,
    off,
    rooter,
    ready,
    box
}
